/*
 * @Author: 黄达全
 * @Date: 2024-07-20 21:46:01
 * @LastEditTime: 2024-08-10 16:45:51
 */
import axios from "../index"
import type { ManagerApi, ApiResponse, LoginVO, ManagerInfoVO, ManagerPageVO ,ManagerXiaLaVO} from "@/common/type"


export default {
    //登录
    async login(form) {
        return (await axios.post("/admin/manager/login", form)).data as ApiResponse<LoginVO>
    },
    //    获取用户信息
    async getUserInfo(): Promise<ApiResponse<ManagerInfoVO>> {
        return (await axios.get("/admin/manager/getInfo")).data as ApiResponse<ManagerInfoVO>
    },
    //    退出登录
    async logout() {
        return (await axios.post("/admin/manager/logout")).data as ApiResponse<null>
    },
    //    获取管理员列表
    async page(page, pageSize,form) {
        return (await axios.post(`/admin/manager/${page}?pageSize=${pageSize}`,form)).data as ApiResponse<ManagerPageVO>
    },
    // 新增管理员
    async add(form) {
        return (await axios.post("/admin/manager", form)).data as ApiResponse<null>
    },
    // 修改管理员
    async update(id, form) {
        return (await axios.put("/admin/manager/" + id, form)).data as ApiResponse<null>
    },
    // 删除管理员、批量删除
    async delete(ids) {
        const queryString = ids.map(id => `ids=${id}`).join('&');
        return (await axios.delete(`/admin/manager?${queryString}`)).data as ApiResponse<null>
    },
    // 批量封禁管理员
    async banned(ids,status) {
        const queryString = ids.map(id => `ids=${id}`).join('&');
        return (await axios.put(`/admin/manager/banned?${queryString}&status=${status}`, ids)).data as ApiResponse<null>
    },
    // 获取下拉列表的管理员列表
    async selectXiaLa() {
        return (await axios.get("/admin/manager/selectXiaLa")).data as ApiResponse<ManagerXiaLaVO[]>
    }
} as ManagerApi